﻿@model List<WebIG.Data.Feed>
@{
    ViewBag.Title = "User";
    Layout = "~/Views/Shared/_Layout.cshtml";
    ViewData["type"] = 1;
}

<div class="user">
    <div class="user-image">
        <div>
            <img src="@ViewBag.User.ProfilePicture" style="width: 110px;height: 110px;" />
        </div>
        <div style="padding-top: 3px;">
            @if (ViewBag.Relation == "Following")
            {
                <button id="btnFollow" class="btn btn-primary btn-xs" style="width: 100%;">@ViewBag.Relation</button>
            }
            else if (ViewBag.Relation == "Requested")
            {
                <button id="btnFollow" class="btn btn-info btn-xs" style="width: 100%;" disabled="disabled">@ViewBag.Relation</button>
            }
            else
            {
                <button id="btnFollow" class="btn btn-default btn-xs" style="width: 100%;">@ViewBag.Relation</button>
            }
        </div>
    </div>
    <div class="user-detail">
        <div>
            <div>@ViewBag.User.FullName (@ViewBag.User.UserName)</div>
            <div>@ViewBag.User.Bio</div>
            <div>
                @if (!string.IsNullOrEmpty(ViewBag.User.WebSite))
                {
                    <a href="@ViewBag.User.WebSite">@ViewBag.User.WebSite</a>
                }
            </div>
            <div>Posts:@ViewBag.User.UserCounts.Media</div>
            <div>Following:@ViewBag.User.UserCounts.Follows</div>
            <div>Followers:@ViewBag.User.UserCounts.FollowedBy</div>
        </div>
    </div>
</div>
<div style="clear: both;margin: 0 -15px; border-bottom: 1px solid #D9D9D9;"></div>
@Html.Partial("_Feeds", @Model, this.ViewData)

@section scripts
{
    <script type="text/javascript">
        $("#btnLoadMore").click(function () {
            $("#btnLoadMore img").show();
            loadMore("@Url.Action("LoadMore")", { type: "@ViewData["type"]", userId: "@ViewBag.User.Id" }, function () {
                $("#btnLoadMore img").hide();
            });
        });

        $("#btnFollow").click(function () {
            $.post("@Url.Action("ModifyRelationship")", { userId: "@ViewBag.User.Id", status: $(this).text() }, function (data) {
                console.log(data);
                if (data == "follows") {
                    $("#btnFollow").text("Following").removeClass("btn-default").addClass("btn-primary");
                }
                else if (data == "none") {
                    $("#btnFollow").text("Follow").removeClass("btn-primary").addClass("btn-default");
                }
            });
        });
    </script>
}






